<?php

/**
 * Name: 风险源服务层
 * User: Silent
 * Date: 2025-10-09
 * Time: 19:35:04
 */

namespace App\Services\Safety;

use App\Repositories\Safety\RiskSourceRepository;
use App\Services\BaseService;
use Illuminate\Support\Facades\Log;

class RiskSourceService extends BaseService
{
    public function __construct(RiskSourceRepository $repository)
    {
        $this->repository = $repository;
    }

    /**
     *  列表.
     *
     * @param array $inputs
     * @return mixed
     */
    public function list(array $inputs)
    {
        return $this->repository->list($inputs);
    }

    /**
     * 添加.
     *
     * @param array $inputs
     * @return array
     */
    public function add(array $inputs): array
    {
        return $this->repository->addData($inputs);
    }

    /**
     * 修改.
     *
     * @param array $inputs
     * @return array
     */
    public function saveData(array $inputs): array
    {
        return $this->repository->saveData($inputs);
    }

    /**
     *  详情.
     *
     * @param int $id
     * @return array
     */
    public function detail(int $id): array
    {
        $query = $this->repository->detail($id);
        if (empty($query)) {
            return ['success' => false, 'message' => '查询失败', 'data' => []];
        }

        return ['success' => true, 'message' => '查询成功', 'data' => $query];
    }

    /**
     *  删除.
     *
     * @param int $id
     * @param mixed $query
     * @return array
     */
    public function delete($query): array
    {
        return $this->repository->destroy($query);
    }
}
